package com.itheima.exer.homework.hw1007.hwtest;

import com.itheima.exer.homework.hw1007.domain.Actor;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * 现在有两个ArrayList集合,分别存储6名男演员和6名女演员,要求完成如下动作:
 * 1.男演员只要名字为3个字的前3人.
 * 2.女演员只要姓林的,并且不要第一个.
 * 3.把过滤后的男演员和女演员的姓名合并到一起.
 * 4.将流中数据收集为List集合.
 */
public class ActorTest1 {
    public static void main(String[] args) {
        ArrayList<Actor> maleActor = new ArrayList<>(List.of(new Actor("大木"),
                new Actor("加藤鹰"), new Actor("王宝强"),
                new Actor("彭于晏"), new Actor("葛优"),
                new Actor("王一博")));
        ArrayList<Actor> femaleActor = new ArrayList<>(List.of(new Actor("林黛玉"),
                new Actor("林青霞"), new Actor("林心如"),
                new Actor("赵薇"), new Actor("范冰冰"),
                new Actor("李冰冰")));
        Stream<Actor> limit = maleActor.stream().filter(s -> s.getName().length() == 3).limit(3);
        Stream<Actor> skip = femaleActor.stream().filter(s -> s.getName().startsWith("林")).skip(1);
        List<Actor> list = Stream.concat(limit, skip).collect(Collectors.toList());
        System.out.println(list);

    }
}
